package com.feinno.module.security.dao;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.Query;

import com.feinno.framework.common.dao.jpa.EntityJpaDao;
import com.feinno.module.security.domain.Menu;

public interface MenuDao extends EntityJpaDao<Menu, Long> {

	@Query("select c,d from Resource c,Role r, Menu d left join r.users u left join r.rescs re where u.id = ?1 and c.id = re.id"
			+ " and c.menu.id=d.id and d.showState = 0 " + " order by d.orderTime desc,c.orderTime desc")
	List<Object> queryAuthorisedMenus(Long userId);

	@Query("select m from Menu m where m.id = ?1")
	Menu getWithHql(Long id);

	@Query("select count(*) from Menu where orderTime > ?1")
	long getCountByGtOrderTime(Date date);

}
